package com.magina.antiPro.controller;

import com.magina.antiPro.bean.ConfigTestBean;
import com.magina.antiPro.dto.Employee;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/testConfig")
public class ConfigTestController {

    @Value("${com.magina.name}")
    private String name;
    @Value("${com.magina.want}")
    private String want;
    @Value("${com.magina.test_want}")
    private String test_want;

    @Value("${magina.uuid}")
    private Object uuid;

    @Autowired
    ConfigTestBean configTestBean;

    @ApiOperation(value="测试从yml配置的参数", notes="")
    @ApiImplicitParam(name = "employee", value = "用户详细实体employee", required = true, dataType = "Employee")
    @PostMapping("/testConfig")
    public String wantTest(@RequestBody Employee employee){
        return "name :" + name + ",want :" + want + ".test :" + test_want;
    }

    @GetMapping("/testBean")
    public String wantBean(){
        return configTestBean.getName() + configTestBean.getWant();
    }

    @PutMapping("/testRandom")
    public String wantRandom(){
        //程序启动之后生成的uuid是一样的
        System.out.println(uuid);
        System.out.println(uuid);
        System.out.println(uuid);
        return uuid.toString();
    }
}
